package com.example.zwh.computershop;

import android.app.Application;

import com.example.zwh.computershop.sqlModel.Cart;
import com.example.zwh.computershop.sqlModel.Order;
import com.example.zwh.computershop.sqlModel.Product;
import com.example.zwh.computershop.sqlModel.User;

import java.util.ArrayList;
import java.util.List;


public class Myapp extends Application {
    //存user
    private User user = new User();

    //订单、产品、购物车数据
    private ArrayList<Order> ora = new ArrayList<>();
    private ArrayList<Cart> carta = new ArrayList<>();
    private ArrayList<Product> products = new ArrayList<>();

    //设置登录状态
    private int LoState = 0;

    public int getLoState() {
        return LoState;
    }
    public User getUser() {
        return user;
    }
    public ArrayList<Order> getOra() {
        return ora;
    }
    public ArrayList<Cart> getCart() {
        return carta;
    }
    public ArrayList<Product> getProducts() {
        return products;
    }
    public void setLoState(int LoState) {
        this.LoState = LoState;
    }
    public void setUser(User user) {
        this.user.setUser(user);
    }
    public void setOra(ArrayList<Order> ora) {
        copyOra(this.ora, ora);
        System.out.println("ora??????");
    }
    public void setCart(ArrayList<Cart> carta) {
        copyCart(this.carta, carta);
        System.out.println("carta??????");
    }

    public void setProducts(ArrayList<Product> products) {
        copyPro(this.products, products);
        System.out.println("products??????");
    }

    public void clearUser() {
        User user = new User();
        this.user.setUser(user);
    }
    public void clearOra() {
        ora.clear();
    }
    public void clearCarta() {
        carta.clear();
    }

    public void copyPro(ArrayList<Product> pos, ArrayList<Product> temp) {
        for (int i = 0; i < temp.size(); i++) {
            pos.add(temp.get(i));
        }
    }
    public void copyOra(ArrayList<Order> pos, ArrayList<Order> temp) {
        for (int i = 0; i < temp.size(); i++) {
            pos.add(temp.get(i));
        }
    }
    public void copyCart(ArrayList<Cart> pos, ArrayList<Cart> temp) {
        for (int i = 0; i < temp.size(); i++) {
            pos.add(temp.get(i));
        }
    }
    public void copyList(List pos, List temp) {
        for (int i = 0; i < temp.size(); i++) {
            pos.add(temp.get(i));
        }
    }
}
